import Mock from 'mockjs'
function randomColor () {
  return '#' + Math.random().toString(16).substr(2, 6).toUpperCase();
}
const top = [
  {
    name: "首页",
    path: "/wel/index",
    icon: 'el-icon-document',
    meta: {
      i18n: 'dashboard',
    },
    parentId: 0
  },
  {
    name: "测试",
    icon: 'el-icon-document',
    path: "/test",
    meta: {
      i18n: 'test',
    },
    parentId: 1
  },
  {
    name: "更多",
    icon: 'el-icon-document',
    path: "/wel/more",
    meta: {
      menu: false,
      i18n: 'more',
    },
    parentId: 2
  },
]

const first = [
  {
    name: "标签",
    path: '/util/tags',
    icon: 'icon-caidan',
    iconBgColor: randomColor(),
    meta: {
      i18n: 'tags',
    },
    children: []
  }, {
    name: "存储",
    path: '/util/store',
    icon: 'icon-caidan',
    iconBgColor: randomColor(),
    meta: {
      i18n: 'store',
    },
    children: []
  }, {
    name: "返回顶部",
    path: '/util/top',
    icon: 'icon-caidan',
    iconBgColor: randomColor(),
    meta: {
      i18n: 'top',
    },
    children: []
  }, {
    name: '多级菜单',
    path: '/util',
    iconBgColor: randomColor(),
    children: [{
      name: '多级菜单1-1',
      path: 'deep',
      iconBgColor: randomColor(),
      children: [{
        name: '多级菜单2-1',
        path: 'deep',
        iconBgColor: randomColor(),
      }]
    }]
  }, {
    name: "关于",
    path: '/util/about',
    icon: 'icon-caidan',
    iconBgColor: randomColor(),
    meta: {
      i18n: 'about',
    },
    children: []
  },
]

export default ({ mock }) => {
  if (!mock) return;
  Mock.mock('/api/system/menu/routes', 'get', () => {
    return {
      data: first || []
    }
  })
  Mock.mock('/api/system/menu/top-menu', 'get', () => {
    return {
      data: top
    }
  })
}